package com.yue.jersey.public_jersey.resource;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import java.io.InputStream;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2016/11/23<br/>
 *
 * @author QiuYang
 */
@Path("file")
public class FileResource {

    @GET
    @Path("txt")
    @Produces
    public Response getTextFile(){
        String path = "download/test.txt";
        InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(path);
        return Response.ok(inputStream).header("Content-Disposition", "attachment;filename=test.txt").build();
    }

//    public static void main(String[] args) {
//        System.out.println(FileResource.class.getClassLoader().getResourceAsStream("download/test.txt"));
//    }
}
